<!DOCTYPE html>
<html lang="zh-CN">
{% include 'common/_header.html' %}
<body>
{% include 'common/_top_nav.html' %}

<div class="container-fluid">
    <div class="row">
        {#左侧导航开始#}
        {% include 'common/_left_nav.html' %}
        {#左侧导航结束#}
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <div class="panel panel-default">
                <div class="row">
                    <div class="my-table-toolbar">
                        <form class="form-inline">
                            <div class="form-group">
                                <label class="sr-only" for="table-search">table search</label>
                                <input type="text" class="form-control" id="table-search" placeholder="搜索">
                            </div>
                            <button class="btn btn-primary">搜索</button>
                            <a class="btn btn-success pull-right" href="/book/publisher/add/">添加</a>
                        </form>
                    </div>
                </div>
                {#出版社表格开始#}
                <div class="my-table-wrapper">
                    <table class="table table-bordered table-striped">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th>名称</th>
                            <th>ISBN</th>
                            <th>地址</th>
                            <th>编码</th>
                            <th>电话</th>
                            <th>传真</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for publisher in publishers %}
                            <tr>
                                <td>{{ forloop.counter }}</td>
                                <td>{{ publisher.name }}</td>
                                <td>{{ publisher.isbn }}</td>
                                <td>{{ publisher.address }}</td>
                                <td>{{ publisher.code }}</td>
                                <td>{{ publisher.telphone }}</td>
                                <td>{{ publisher.fax }}</td>
                                <td>
                                    <a type="button" class="btn btn-sm btn-success" aria-label="Left Align"
                                       href="/publisher/edit/?id={{ publisher.id }}">
                                        <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>编辑
                                    </a>
                                    <a type="button" class="btn btn-sm btn-danger" aria-label="Left Align"
                                       href="javascript:deletePublisher({{ publisher.id }});">
                                        <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
                                    </a>
                                </td>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                    <div class="row">
                        <div class="col-md-7 col-xs-12 pull-right">
                            {{ page|safe }}
                        </div>
                    </div>
                </div>
                {#出版社表格结束#}
            </div>
        </div>
    </div>
</div>
<script>
    function deletePublisher(id) {
        if (confirm(`即将删除id为${id}的出版社, 是否确认? `)) {
            window.location.href = '{% url 'book:publisher_delete' %}?id=' + id
        }
    }
</script>
</body>
</html>